package lupita.model.vos;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class FileSystemItem implements Serializable {


	/**
	 * 
	 */
	private static final long serialVersionUID = 2291464528347762338L;

	private Long id;
	
	private String fName;
	
	private String fPath;
	
	private Double fLength;	
	
	private List<Map<String, String>> fields  = new ArrayList<Map<String,String>>();
	
	private Rating rating;
	
	private List<WordFileTag> tags = new ArrayList<WordFileTag>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFileName() {
		return fName;
	}

	public void setFileName(String name) {
		this.fName = name;
	}
	
	public String getOrderSystemNameFile(){
		if ( this.fName.length() > 15 ){
			String extension = fName.split("\\.")[1];
			return this.fName.substring(0, 14) + "..." + extension;
		}
		return this.fName;		
	}
	
	public String getFileExtension(){
		return fName.split("\\.")[1];
	}

	public String getFullPath() {
		return fPath;
	}

	public void setFullPath(String allPath) {
		this.fPath = allPath;
	}

	public Double getLengthFile() {
		if(fLength != null) {
			double length = fLength/1024;        
	        int decimal = 2;
	        BigDecimal bd = new BigDecimal(length);
	        bd = bd.setScale(decimal, BigDecimal.ROUND_DOWN);
	        length = bd.doubleValue();
			
			return length;
		}
		return fLength;
	}

	public void setFileLength(Double length) {
		this.fLength = length;
	}

	public List<Map<String, String>> getFields() {
		return fields;
	}

	public void setFields(List<Map<String, String>> fields) {
		this.fields = fields;
	}

	public Rating getRating() {
		return rating;
	}

	public void setRating(Rating rating) {
		this.rating = rating;
	}

	public List<WordFileTag> getTags() {
		return tags;
	}

	public void setTags(List<WordFileTag> tags) {
		this.tags = tags;
	}
	
	public String getShortFileName(){
		if ( this.fName.length() > 15 ){
			String extension = fName.split("\\.")[1];
			return this.fName.substring(0, 14) + "..." + extension;
		}
		return this.fName;		
	}
	
	public Double getFileLength() {
		if(fLength != null) {
			double length = fLength/1024;        
	        int decimalPlace = 2;
	        BigDecimal bd = new BigDecimal(length);
	        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_DOWN);
	        length = bd.doubleValue();
			
			return length;
		}
		return fLength;
	}
	
}
